package com.briup.estore.userAPI.web.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.Set;

/**
 * @author adam
 * @date 2022/11/25
 */
@RestController
@Slf4j
public class LogController {

    @GetMapping("log")
    public void logSave(HttpServletRequest request) {
        StringBuffer sb = new StringBuffer();
        String addr = request.getLocalAddr();
        long timeMillis = System.currentTimeMillis();
        Map<String, String[]> map = request.getParameterMap();
        Set<String> set = map.keySet();
        sb.append(addr).append("||");
        set.forEach(key -> {
            String param = request.getParameter(key);
            sb.append(param).append("||");
        });

        sb.append(timeMillis);
        //log.info(sb.toString());

    }
}
